﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Animation;
using Asko.Lib.Views;
using System.Windows.Media;
using System.Windows;

namespace Asko.Lib.Controls.Animations
{
    public class SimpleAnimation
    {
        private static TimeSpan _duration = new TimeSpan(0, 0, 0, 0,100);
        #region Méthodes
        public void Animate()
        {
            var animationX = new DoubleAnimation(
                Node.X,
                Position.X,
                _duration,
                FillBehavior.Stop);            
            animationX.Completed += (s, f) =>
            {
                Node.SetValue(NodeView.XProperty, Position.X);
                Node.SetValue(NodeView.YProperty, Position.Y);
                TranslateTransform tt = new TranslateTransform(Position.X, Position.Y);
                Node.RenderTransform = tt;
               
            };
            Node.BeginAnimation(NodeView.XProperty, animationX, HandoffBehavior.Compose);
        }

        #endregion

        #region Propriétés
        public NodeView Node
        {
            get;
            set;
        }
        public Point Position
        {
            get;
            set;
        }
        #endregion
    }
}
